{include file="common/_meta" /}
<title>下载列表 - 下载管理 </title>
<meta name="keywords" content="李志立，lizhilimaster@163.com">
<meta name="description" content="李志立，lizhilimaster@163.com">
</head>
<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		下载管理
		<span class="c-gray en">&gt;</span>
		下载列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-download">
		<article class="cl pd-20">
			<div class="text-c">
				<form action="" method="get">
					<input type="text" class="input-text" style="width:250px" value="{$data.key}" placeholder="输入下载标题名称" id="" name="key">
					<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜下载</button>
				</form>
			</div>
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<a href="javascript:;" onclick="data_del()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>
						批量删除</a>
					<a class="btn btn-primary radius" data-title="添加下载"  onclick="download_add('添加下载','{:url('download/add')}')"
					 href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加下载</a>
				</span>
				<span class="r">共有数据：<strong>{$count1}</strong> 条</span>
			</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="" value=""></th>
							<th width="40">ID</th>
							<th width="100">标题</th>
							<th width="40">来源</th>
							<th width="40">作者</th>
							<th width="80">缩率图</th>
							<th width="200">简介</th>
							<th width="100">查看附件</th>
							<th width="80">发布时间</th>
							<th width="50">展示数据</th>
							<th width="50">浏览次数</th>
							<th width="50">推荐状态</th>
							<th width="50">是否隐藏</th>
							<th width="70">操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="info" id="vo"}
						<tr class="text-c">
							<td><input type="checkbox" class="all" value="{$vo.id}" name=""></td>
							<td>{$vo.id}</td>
							<td class="text-l">{$vo.title}</td>
							<td>{$vo.laiyuan|default="没有填写"}</td>
							<td>{$vo.author|default="佚名"}</td>
							<td>
								{if condition="$vo.pic == '' "}
								暂无缩率图
								{else /}
								<img src="{$vo.pic}" height="50" />
								{/if}
							</td>
							<td>{$vo.desc|default="没有填写"}</td>
							<td><a class="btn btn-secondary radius" target="_blank" href="{$vo.file}">点击打开文件</a> </td>
							<td>{$vo.create_time|date='Y-m-d H:i:s'}</td>
							<td>{$vo.click_wai}</td>
							<td>{$vo.click}</td>
							<td class="td-status">
								{if condition="$vo.is_tui == 0"}
								<span class="label label-disabled radius">不推荐</span>
								{else /}
								<span class="label label-success radius">推荐</span>
								{/if}
							</td>
							<td class="td-status1">
								{switch name="vo.isopen" }
								{case value="1"}<span class="label label-success radius">展示</span>{/case}
								{case value="0"}<span class="label label-default radius">隐藏</span>{/case}
								{/switch}
							</td>
							<td class="f-14 td-manage">
								{if condition="$vo.isopen == 1 "}
								<a style="text-decoration:none" onclick="download_stop(this,{$vo.id})" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>
								{else /}
								<a onclick="download_start(this,{$vo.id})" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>
								{/if}
								<a style="text-decoration:none" class="ml-5" onclick="download_add('编辑下载','{:url('download/edit',['id'=>$vo.id])}')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
								<a style="text-decoration:none" class="ml-5" onclick="download_del(this,{$vo.id})" href="javascript:;" title="删除"><i
									 class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
				{$info|raw}
			</div>
		</article>
	</div>
	{include file="common/_footer" /}
	<script type="text/javascript">
		/*下载-添加*/
		function download_add(title, url, w, h) {
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		function download_all(title, url, w, h) {
			layer_show(title,url,w,h);
		}
		
		/*下载-编辑*/
		function download_edit(title, url, w, h) {
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		/*下载-删除*/
		function download_del(obj, id) {
			layer.confirm('确认要删除吗？', function(index) {
				$.post(
					"{:url('download/ajax')}", {
						id: id,
						type: 'download_del',
					},
					function(result) {
						if (result.code === 1) {
							$(obj).parents("tr").remove();
							layer.msg('已删除!', {
								icon: 1,
								time: 1000
							});
							
						} else {
							layer.msg('删除失败!', {
								icon: 5,
								time: 1000
							});
						}
					});
			});
		}
		/*自己编写管理员-批量删除*/
		function data_del() {
			var arr = new Array();
			$("input[type='checkbox']:gt(0):checked").each(function() {
				arr.push($(this).attr("value"));
			});
			if (arr.length < 1) {
				alert("请至少选择一个");
			} else {
				layer.confirm('确认要删除吗？', function(index) {
					$.post(
						"{:url('download/ajax')}", {
							id: arr,
							type: 'download_all',
						},
						function(result) {
							if (result.code === 1) {
								layer.msg('批量删除成功!', {
									icon: 1,
									time: 1000
								},function (){
									history.go(0);
								});

							} else {
								layer.msg('批量删除失败!', {
									icon: 5,
									time: 1000
								});
							}
						});
				});
			}
		}
		function download_stop(obj, id) {
			layer.confirm('确认要停用吗？', function(index) {
				//此处请求后台程序，下方是成功后的前台处理……
				$.post(
					"{:url('download/ajax')}", {
						id: id,
						type: 'download_stop',
					},
					function(result) {
						if (result.code === 1) {
							layer.msg('已停用!', {
								icon: 5,
								time: 1000
							},function (){
								location.reload();
							});
						} else {
							layer.msg('停用失败!', {
								icon: 5,
								time: 1000
							});
						}
					});
			});
		}
		
		/*管理员-启用*/
		function download_start(obj, id) {
			layer.confirm('确认要启用吗？', function(index) {
				$.post(
					"{:url('download/ajax')}", {
						id: id,
						type: 'download_start',
					},
					function(result) {
						if (result.code === 1) {
							layer.msg('已启用!', {
								icon: 6,
								time: 1000
							},function (){
								location.reload();
							});
						} else {
							layer.msg('启动失败!', {
								icon: 5,
								time: 1000
							});
						}
					});
			});
		}
	</script>
</body>
</html>
